package com.ecp.pay.wx.util;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;

public class HttpClientUtil {

	public static String getResult(PostMethod postMethod) {
		String result = "";
		HttpClient httpClient = new HttpClient();
		try {
			int _state = httpClient.executeMethod(postMethod);
			if (_state == 200) {
				InputStream is = postMethod.getResponseBodyAsStream();
				BufferedReader reader = new BufferedReader(new InputStreamReader(is, "ISO-8859-1"));
				String tmp = null;
				String htmlRet = "";
				while ((tmp = reader.readLine()) != null) {
					htmlRet += tmp + "\r\n";
				}
				result = new String(htmlRet.getBytes("ISO-8859-1"), "GB2312");
			}
		} catch (Exception e) {

		} finally {
			postMethod.releaseConnection();
		}
		return result;
	}

}
